package com.anji.hyperneat.onlinereinforcement;

import com.anji.hyperneat.nd.NDFloatArray;
import com.anji.hyperneat.nd.NDFloatArray.MatrixIterator;
import com.anji.nn.activationfunction.ActivationFunction;

public abstract class OnlineLearningActivatorNDBase implements IOnlineLearningActivatorND {

	protected ActivatorNDLR original;
	protected ActivatorNDLR working;
	
	public OnlineLearningActivatorNDBase(ActivatorNDLR phenotype) {
		this.original = phenotype.clone();
		original.reset();
		this.working = original.clone();
	}
	
		
	@Override
	public void setInputs(NDFloatArray inputs) {working.setInputs(inputs);}
	@Override
	public NDFloatArray getInputs() {return working.getInputs();}
	@Override
	public NDFloatArray getOutputs() {return working.getOutputs();}
	@Override
	public boolean isFeedForward() {return working.isFeedForward();}
	@Override
	public NDFloatArray next(NDFloatArray stimuli) {return working.next(stimuli);}
	@Override
	public NDFloatArray[] nextSequence(NDFloatArray[] stimuli) {return working.nextSequence(stimuli);}
	@Override
	public void reset() {working.reset();}
	@Override
	public NDFloatArray getLayer(int layer) {return working.getLayer(layer);}
	@Override
	public int getNumLayers() {return working.getNumLayers();}
	
	@Override
	public String getName() {
		return working.getName();
	}

	/**
	 * Resets all learning to the state of this activator at its time of creation.
	 */
	public void resetLearning() {working = original.clone();}

	@Override
	public void setName(String string) {
		working.setName(string);
	}



	@Override
	public int[] getInputDimension() {
		return working.getInputDimension();
	}



	@Override
	public int[] getOutputDimension() {
		return working.getOutputDimension();
	}



	@Override
	public NDFloatArray[] getWeights() {
		return working.getWeights();
	}



	@Override
	public NDFloatArray[] getBias() {
		return working.getBias();
	}



	@Override
	public long cost() {
		return working.cost();
	}



	@Override
	public int getConnectionCount(boolean includeBias) {
		return working.getConnectionCount(includeBias);
	}



	@Override
	public NDFloatArray[] getLayers() {
		return working.getLayers();
	}
	
	@Override
	public ActivationFunction getActivationFunction() {
		return working.getActivationFunction();
	}
	


	@Override
	public abstract void updateNet(NDFloatArray desiredOuts);
	@Override
	public abstract void updateNet(NDFloatArray desiredOuts, float learningRateModifier);	
	
	@Override
	public ActivatorNDLR getWorkingActivator() {return working;}

	@Override
	public ActivatorNDLR getOriginalActivator() {return original;}

}
